<template>
  <div class="basic-info-wrapper">
    <div class="flex flex-wrap justify-between">
      <div class="mb-5 w-49">
        <div class="mb-3 text-base font-medium">费用明细</div>
        <div class="flex bg-f7f8fa justify-evenly">
          <div class="w-full">
            <div class="flex flex-col justify-center items-center py-2.5 bg-eef0f4">
              <div class="font-medium">费用总额</div>
              <div class="text-1890ff font-medium">{{ amountCount.totalAmount ?? '-' }} 元</div>
            </div>
            <a-divider class="outline-e5e6eb" margin="0" />
            <div class="flex flex-col items-center justify-center py-4">
              <div class="mb-2">线上总额：{{ amountCount.totalOnlineAmount ?? '-' }} 元</div>
              <div>线下总额：{{ amountCount.totalOfflineAmount ?? '-' }} 元</div>
            </div>
          </div>
          <a-divider class="outline-e5e6eb" direction="vertical" margin="0" />
          <div class="w-full">
            <div class="flex flex-col justify-center items-center py-2.5 bg-eef0f4">
              <div class="font-medium">收款总额</div>
              <div class="text-1890ff font-medium">{{ amountCount.receivedAmount ?? '-' }} 元</div>
            </div>
            <a-divider class="outline-e5e6eb" margin="0" />
            <div class="flex flex-col items-center justify-center py-4">
              <div class="mb-2">线上实收：{{ amountCount.receivedOnlineAmount ?? '-' }} 元</div>
              <div>线下实收：{{ amountCount.receivedOfflineAmount ?? '-' }} 元</div>
            </div>
          </div>
          <a-divider class="outline-e5e6eb" direction="vertical" margin="0" />
          <div class="w-full">
            <div class="flex flex-col justify-center items-center py-2.5 bg-eef0f4">
              <div class="font-medium">付款总额</div>
              <div class="text-1890ff font-medium">{{ amountCount.payAmount ?? '-' }} 元</div>
            </div>
            <a-divider class="outline-e5e6eb" margin="0" />
            <div class="flex flex-col items-center justify-center py-4">
              <div class="mb-2">线上实付：{{ amountCount.payOnlineAmount ?? '-' }} 元</div>
              <div>线下实付：{{ amountCount.payOfflineAmount ?? '-' }} 元</div>
            </div>
          </div>
          <a-divider v-if="shortOrderDetails?.orderSource != 1" class="outline-e5e6eb" direction="vertical" margin="0" />
          <div class="w-full" v-if="shortOrderDetails?.orderSource != 1">
            <div class="flex flex-col justify-center items-center py-2.5 bg-eef0f4">
              <div class="font-medium">OTA对账总额</div>
              <div class="text-1890ff font-medium">{{ amountCount.statementTotalAmount ?? '-' }} 元</div>
            </div>
            <a-divider class="outline-e5e6eb" margin="0" />
            <div class="flex flex-col items-center justify-center py-4">
              <div class="mb-2">佣金：{{ amountCount.commissionAmount ?? '-' }} 元</div>
              <div>
                <a-link @click="onChangeCommission">
                  <template #icon>
                    <icon-edit />
                  </template>
                  设置抽佣比例
                </a-link>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="w-49" v-if="amountCount.statementInfoList?.length">
        <div class="mb-3 text-base font-medium">结算明细</div>
        <div class="flex bg-f7f8fa justify-evenly">
          <template v-for="(item, index) in amountCount.statementInfoList" :key="item.feeStatusName">
            <div class="w-full">
              <div class="flex flex-col justify-center items-center py-2.5 bg-eef0f4">
                <div class="font-medium">{{ item.feeStatusName ?? '-' }}</div>
                <div class="text-1890ff font-medium">{{ item.totalAmount ?? '-' }} 元</div>
              </div>
              <a-divider class="outline-e5e6eb" margin="0" />
              <div class="flex flex-col items-center justify-center py-4">
                <div class="mb-2">收款：{{ item.collectAmount ?? '-' }} 元</div>
                <div v-if="item.feeStatus != 1">付款：{{ item.payAmount ?? '-' }} 元</div>
              </div>
            </div>
            <a-divider v-if="index < amountCount.statementInfoList.length" class="outline-e5e6eb" direction="vertical" margin="0" />
          </template>
        </div>
      </div>
      <div class="w-full" v-if="amountCount.depositInfoList?.length">
        <div class="mb-3 text-base font-medium">
          押金信息
          <a-button
            v-if="depositShow && amountCount.depositOrderId && shortOrderDetails.orderSource == 1"
            type="primary"
            size="mini"
            @click="onViewDeposit"
            >查看免押码</a-button
          >
        </div>
        <div class="flex flex-wrap">
          <template v-for="(item, index) in amountCount.depositInfoList" :key="item.depositName">
            <div class="flex mb-4">
              <div class="w-44 bg-f7f8fa">
                <div class="flex flex-col justify-center items-center py-2.5">
                  <div class="font-medium">{{ item.depositName }}</div>
                  <div class="text-1890ff font-medium">{{ item.amount ?? '-' }} 元</div>
                  <a-tag v-if="item.payTypeName" class="text-191c27" color="#E0E6F3">{{ item.payTypeName }}</a-tag>
                </div>
              </div>
              <a-divider v-if="index < amountCount.depositInfoList.length - 1" class="outline-e5e6eb" direction="vertical" margin="0" />
            </div>
          </template>
        </div>
      </div>
    </div>
    <list-deposit-modal ref="depositModalRef" />
  </div>
</template>
<script setup lang="ts">
  import { ref, inject } from 'vue'
  import listDepositModal from '../../components/alipay-deposit/list-deposit-modal.vue'
  import { getDepositShow } from '../../utils.js'

  const depositModalRef = ref()
  const props = defineProps({
    amountCount: {
      type: Object,
      default: () => ({}),
    },
  })

  const depositShow = ref(false)
  //查询芝麻免押是否开启
  getDepositShow().then((depositInfo: any) => {
    depositShow.value = depositInfo.alipaySwitch
  })
  const shortOrderDetails: any = inject('getShortOrderDetail')

  const emits = defineEmits(['onChangeCommission'])

  const onChangeCommission = () => {
    emits('onChangeCommission')
  }

  const onViewDeposit = () => {
    depositModalRef.value.show(shortOrderDetails.value)
  }
</script>
<style lang="less" scoped>
  .w-49 {
    width: 49.5%;
  }

  .bg-f7f8fa {
    background: #f7f8fa;
  }

  .bg-eef0f4 {
    background: #eef0f4;
  }

  .outline-e5e6eb {
    border-color: #e5e6eb;
  }

  .text-191c27 {
    color: #191c27;
  }

  .text-1890ff {
    color: #1890ff;
  }

  .color-1890ff {
    color: #1890ff;
  }

  .view-deposit {
  }
</style>
